package com.sskj.api.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sskj.api.domain.UserLoginLog;
import com.sskj.api.domain.UserOperationLog;
import com.sskj.api.service.IUserLoginLogService;
import com.sskj.api.service.IUserOperationLogService;
import com.sskj.api.vo.req.UserLoginLogReq;
import com.sskj.api.vo.req.UserOperationLogReq;
import com.sskj.common.util.ApiResponseUtil;
import com.sskj.common.vo.ApiResponse;
import com.sskj.common.vo.SimplePagination;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "审计中心")
@RestController
@RequestMapping("/admin/auditLog")
public class AuditLogController {

    @Autowired
    private IUserLoginLogService userLoginLogService;

    @Autowired
    private IUserOperationLogService userOperationLogService;

    @Operation(summary = "用户登录日志")
    @GetMapping("loginLog/pagelist")
    public ApiResponse<SimplePagination<UserLoginLog>> loginLogPageList(UserLoginLogReq req) {
        IPage<UserLoginLog> userLoginLogIPage = userLoginLogService.pageList(req);

        return ApiResponseUtil.success(userLoginLogIPage);
    }

    @Operation(summary = "用户操作日志")
    @GetMapping("operationLog/pageList")
    public ApiResponse<SimplePagination<UserOperationLog>> operationLogPageList(UserOperationLogReq req) {
        IPage<UserOperationLog> userOperationLogIPage = userOperationLogService.pageList(req);

        return ApiResponseUtil.success(userOperationLogIPage);
    }
}
